From a72950108d521108b45133b5abb58737962d1379 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Thu, 8 May 2014 13:13:38 -0700 Subject: [PATCH] Cleanup ProcessBuilder --- src/cargo/util/process_builder.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 0a0fb3de1..4356dcab6 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -3,7 +3,6 @@ use std::path::Path; use std::io; use std::io::process::{Process,ProcessConfig,ProcessOutput,InheritFd}; use collections::HashMap; -use core::errors::{ToResult,CargoResult,CargoError}; #[deriving(Clone,Eq)] pub struct ProcessBuilder { @@ -59,24 +58,13 @@ impl ProcessBuilder { } } - // TODO: Match exec() - pub fn exec_with_output(&self) -> CargoResult { - let mut config = ProcessConfig::new(); - - config.program = self.program.as_slice(); - config.args = self.args.as_slice(); - config.cwd = Some(&self.cwd); - - let os_path = try!(os::getenv("PATH").to_result(|_| - CargoError::described("Could not find the PATH environment variable"))); - - let path = os_path + PATH_SEP + self.path.connect(PATH_SEP); + pub fn exec_with_output(&self) -> io::IoResult { + let mut config = try!(self.build_config()); + let env = self.build_env(); - let path = [("PATH".to_owned(), path)]; - config.env = Some(path.as_slice()); + config.env = Some(env.as_slice()); - Process::configure(config).map(|mut ok| ok.wait_with_output()).to_result(|_| - CargoError::described("Could not spawn process")) + Process::configure(config).map(|mut ok| ok.wait_with_output()) } fn build_config<'a>(&'a self) -> io::IoResult> { -- 2.30.2